#!/usr/bin/python
#
# Chinwei Hu, Apr 2010
#
# format_count.py takes mlist.py and turns it into the lda.c format
#
# ./format_count.py>cnxlda.txt

import pickle

def main():
  mlist = pickle.load(open('mlist.p','rU'))
  vocab = pickle.load(open('vocab.p','rU'))
  lda_xform(mlist,vocab)

def lda_xform(mlist,vocab):
  for mod in mlist:
    print len(mod.keys()),
    for count in mod.items():
      print str(vocab.index(count[0]))+':'+str(count[1]),
    print '\n',
  
if __name__ == '__main__':
  main()